package cc.chinagps.gateway.common;


import cc.chinagps.gateway.util.PropertiesUtil;
import cc.chinagps.gateway.util.SystemConfig;

public final class Config {
    public static void refreshConfig() {
        SYS.DEVICE_REFRESH_INTERVAL = PropertiesUtil.getLong("device_refresh_interval", 120000L);
        SYS.GPS_DELIVER_INTERVAL = PropertiesUtil.getLong("gps_deliver_interval", 60000L);
        SYS.DIESEL_DELIVER_INTERVAL = PropertiesUtil.getLong("diesel_deliver_interval", 10000L);
        SYS.OBD_DELIVER_INTERVAL = PropertiesUtil.getLong("obd_deliver_interval", 86400000L);
        SYS.LOGIN_DELIVER_INTERVAL = PropertiesUtil.getLong("login_deliver_interval", 90000L);
        SYS.CHECK_LOGIN_INTERVAL = PropertiesUtil.getLong("check_login_interval", 5000L);
        SYS.SEND_OBD_INTERVAL = PropertiesUtil.getLong("send_obd_interval", 90000L);
        SYS.PACKET_TYPE_LIST = PropertiesUtil.getString("packet_type_list");
        SYS.TRANSFER_SERVER_IP = PropertiesUtil.getString("transfer_server_ip");
        SYS.TRANSFER_SERVER_PORT = PropertiesUtil.getInteger("transfer_server_port", 12000);
        SYS.TRANSFER_SERVER_OBD_PORT = PropertiesUtil.getInteger("transfer_server_obd_port", 12000);
        SYS.DEVICE_IDLE_TIME_MAX = Long.parseLong(SystemConfig.getSystemProperty("unit_session_timeout")) + PropertiesUtil.getLong("device_idle_time_offset", 120000L);
        SYS.THREAD_BOSS_NUM = PropertiesUtil.getInteger("thread_boss_num", 64);
        SYS.THREAD_WORKER_NUM = PropertiesUtil.getInteger("thread_worker_num", 64);
        SYS.ENCRYPT_ENABLED = PropertiesUtil.getBoolean("encrypt_enabled", false);
        SYS.ENCRYPT_TYPE = PropertiesUtil.getInteger("encrypt_type", 1);
        SYS.SIGNATURE_ENABLED = PropertiesUtil.getBoolean("signature_enabled", false);
        SYS.TRANSFER_ENABLED = PropertiesUtil.getBoolean("transfer_enabled", false);
        SYS.RECONNECT_ENABLED = PropertiesUtil.getBoolean("reconnect_enabled", false);
        SYS.CHECK_DELIVER_INTERVAL_ENABLED = PropertiesUtil.getBoolean("check_deliver_interval_enabled", true);
        SYS.MAX_RETRY_COUNT = PropertiesUtil.getInteger("max_retry_count", 10);
        SYS.SUCCESS_MODE = PropertiesUtil.getInteger("success_mode", 1);
        SYS.RESPONSE_TIMEOUT = PropertiesUtil.getLong("response_timeout", 5000L);
        SYS.LOGIN_ENCRYPT = PropertiesUtil.getBoolean("login_encrypt", false);
    }

    public static class SYS {
        public static int CLIENT_ID = PropertiesUtil.getInteger("client_id", 323);
        public static Long DEVICE_REFRESH_INTERVAL = PropertiesUtil.getLong("device_refresh_interval", 120000L);
        public static Long GPS_DELIVER_INTERVAL = PropertiesUtil.getLong("gps_deliver_interval", 60000L);
        public static Long DIESEL_DELIVER_INTERVAL = PropertiesUtil.getLong("diesel_deliver_interval", 10000L);
        public static Long OBD_DELIVER_INTERVAL = PropertiesUtil.getLong("obd_deliver_interval", 86400000L);
        public static Long LOGIN_DELIVER_INTERVAL = PropertiesUtil.getLong("login_deliver_interval", 90000L);
        public static Long CHECK_LOGIN_INTERVAL = PropertiesUtil.getLong("check_login_interval", 5000L);
        public static Long SEND_OBD_INTERVAL = PropertiesUtil.getLong("send_obd_interval", 90000L);
        public static String PACKET_TYPE_LIST = PropertiesUtil.getString("packet_type_list");
        public static String TRANSFER_SERVER_IP = PropertiesUtil.getString("transfer_server_ip");
        public static int TRANSFER_SERVER_PORT = PropertiesUtil.getInteger("transfer_server_port", 12000);
        public static int TRANSFER_SERVER_OBD_PORT = PropertiesUtil.getInteger("transfer_server_obd_port", 12000);
        //public static int DEVICE_IDLE_TIME_MAX = PropertiesUtil.getInteger("device_idle_time_offset", 120000);
        public static long DEVICE_IDLE_TIME_MAX = Long.parseLong(SystemConfig.getSystemProperty("unit_session_timeout")) + PropertiesUtil.getLong("device_idle_time_offset", 120000L);
        public static int THREAD_BOSS_NUM = PropertiesUtil.getInteger("thread_boss_num", 64);
        public static int THREAD_WORKER_NUM = PropertiesUtil.getInteger("thread_worker_num", 64);
        public static boolean ENCRYPT_ENABLED = PropertiesUtil.getBoolean("encrypt_enabled", false);
        public static Integer ENCRYPT_TYPE = PropertiesUtil.getInteger("encrypt_type", 1);
        public static boolean SIGNATURE_ENABLED = PropertiesUtil.getBoolean("signature_enabled", false);
        public static boolean TRANSFER_ENABLED = PropertiesUtil.getBoolean("transfer_enabled", false);
        public static boolean RECONNECT_ENABLED = PropertiesUtil.getBoolean("reconnect_enabled", false);
        public static boolean CHECK_DELIVER_INTERVAL_ENABLED = PropertiesUtil.getBoolean("check_deliver_interval_enabled", true);
        public static Integer MAX_RETRY_COUNT = PropertiesUtil.getInteger("max_retry_count", 10);
        public static Integer SUCCESS_MODE = PropertiesUtil.getInteger("success_mode", 1);
        public static Long RESPONSE_TIMEOUT = PropertiesUtil.getLong("response_timeout", 5000L);
        public static boolean LOGIN_ENCRYPT = PropertiesUtil.getBoolean("login_encrypt", false);
    }

    public static class MQ {
        public static String URL = SystemConfig.getMQProperty("url");
        public static int COMPRESS_SIZE = Integer.valueOf(SystemConfig.getMQProperty("compress_size"));
        public static String EG_PACKET_NAME = SystemConfig.getMQProperty("queue_name_egmp_packet");
        public static int EG_PACKET_TYPE = Integer.valueOf(SystemConfig.getMQProperty("queue_type_egmp_packet"));
        public static int EG_PACKET_MODE = Integer.valueOf(SystemConfig.getMQProperty("queue_mode_egmp_packet"));
        public static int EG_PACKET_CACHE_SIZE = Integer.valueOf(SystemConfig.getMQProperty("queue_cache_size_egmp_packet"));
    }

    public interface REDIS {
        String HOST = PropertiesUtil.getString("redis_host");
        int PORT = PropertiesUtil.getInteger("redis_port", 6379);
        int TIMEOUT = PropertiesUtil.getInteger("redis_timeout", 5000);
        int MIN_IDLE = PropertiesUtil.getInteger("redis_pool_min-idle", 0);
        int MAX_IDLE = PropertiesUtil.getInteger("redis_pool_max-idle", 10);
        int MAX_ACTIVE = PropertiesUtil.getInteger("redis_pool_max-active", 1024);
        long MAX_WAIT_MILLIS = PropertiesUtil.getInteger("redis_pool_max-wait", 10000);
        boolean BLOCK_WHEN_EXHAUSTED = PropertiesUtil.getBoolean("redis_block-when-exhausted", false);
    }

    public static class MYSQL {
        public static String SQL_LIST_TRANSFER_DEVICE = PropertiesUtil.getString("sql_list_transfer_device");
    }

}
